/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.TransactionTypeDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.TransactionTypeDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.TransactionTypeDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_transaction_type.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisTransactionTypeDAO extends SqlMapClientDaoSupport implements TransactionTypeDAO {

    /**
     *  Query DB table <tt>sgw_transaction_type</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select trans_type_id, trans_type_name, router_type, memo, gmt_create, gmt_modified, origin_channel_system_id from sgw_transaction_type</tt>
     *
     *	@return List<TransactionTypeDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<TransactionTypeDO> loadAll() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-TRANSACTION-TYPE-LOAD-ALL", null);

    }

    /**
     *  Insert one <tt>TransactionTypeDO</tt> object to DB table <tt>sgw_transaction_type</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_transaction_type(trans_type_id,trans_type_name,router_type,memo,gmt_create,gmt_modified,origin_channel_system_id) values (?, ?, ?, ?, ?, sysdate, sysdate, ?)</tt>
     *
     *	@param transactionType
     *	@return String
     *	@throws DataAccessException
     */
    public String insert(TransactionTypeDO transactionType) throws DataAccessException {
        if (transactionType == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-TRANSACTION-TYPE-INSERT", transactionType);

        return transactionType.getTransTypeId();
    }

    /**
     *  Query DB table <tt>sgw_transaction_type</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select trans_type_id, trans_type_name, router_type, memo, gmt_create, gmt_modified, origin_channel_system_id from sgw_transaction_type where ((trans_type_id = ?) AND (router_type = ?))</tt>
     *
     *	@param transTypeId
     *	@param routerType
     *	@return List<TransactionTypeDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public List<TransactionTypeDO> select(String transTypeId, String routerType)
                                                                                throws DataAccessException {
        Map param = new HashMap();

        param.put("transTypeId", transTypeId);
        param.put("routerType", routerType);

        return getSqlMapClientTemplate().queryForList("MS-TRANSACTION-TYPE-SELECT", param);

    }

    /**
     *  Update DB table <tt>sgw_transaction_type</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_transaction_type set trans_type_name=?, router_type=?, memo=?, gmt_modified=sysdate, origin_channel_system_id=? where (trans_type_id = ?)</tt>
     *
     *	@param transTypeName
     *	@param routerType
     *	@param memo
     *	@param originChannelSystemId
     *	@param transTypeId
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public int update(String transTypeName, String routerType, String memo,
                      String originChannelSystemId, String transTypeId) throws DataAccessException {
        Map param = new HashMap();

        param.put("transTypeName", transTypeName);
        param.put("routerType", routerType);
        param.put("memo", memo);
        param.put("originChannelSystemId", originChannelSystemId);
        param.put("transTypeId", transTypeId);

        return getSqlMapClientTemplate().update("MS-TRANSACTION-TYPE-UPDATE", param);
    }

    /**
     *  Delete records from DB table <tt>sgw_transaction_type</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_transaction_type where (trans_type_id = ?)</tt>
     *
     *	@param transTypeId
     *	@return int
     *	@throws DataAccessException
     */
    public int delete(String transTypeId) throws DataAccessException {

        return getSqlMapClientTemplate().delete("MS-TRANSACTION-TYPE-DELETE", transTypeId);
    }

}